package design_mode.代理.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class SubjectProxy<T> implements InvocationHandler {

    private T subject;

    public SubjectProxy(T subject) {
        this.subject = subject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("method " + method.getName() + "invoke by proxy, start");

        Object o = method.invoke(subject, args);

        System.out.println("method " + method.getName() + "invoke by proxy, end");
        return o;
    }
}